package com.kanshu.ksgb.fastread.doudou.module.book.utils;

import com.kanshu.ksgb.fastread.doudou.module.book.bean.SimpleChapterBean;
import com.kanshu.ksgb.fastread.doudou.module.book.bean.ChapterBean;

/**
 * chapterbean数据转SimpleChapterBean结构适配器
 * 作者    wcy
 * 时间    2018/12/6 16:32
 * 文件    doudou
 * 描述
 */
public class SimpleChapterAdapter {
    /**
     * 数据类型适配
     * @param bean
     * @return
     */
    public static SimpleChapterBean changeToSimpleChapter(ChapterBean bean) {
        SimpleChapterBean item = null;
        if (bean != null) {
            item = new SimpleChapterBean();
            item.book_id = bean.book_id;
            item.content_id = bean.content_id;
            item.title = bean.title;
            item.order = bean.order;
            item.price = bean.price;
            if (bean.last_chapter != null) {
                item.last_content_id = bean.last_chapter.content_id;
                item.last_order = bean.last_chapter.order;
            }
            if (bean.next_chapter != null) {
                item.next_content_id = bean.next_chapter.content_id;
                item.next_order = bean.next_chapter.order;
            }
            if (bean.book_info != null) {
                item.book_title = bean.book_info.book_title;
                item.chapter_count = bean.book_info.chapter_count;
            }
        }
        return item;
    }

}
